package mrpheu.demo.server.implement;

import java.util.Map.Entry;
import java.util.Map;
import java.util.Set;

import mrpheu.demo.server.bean.MessageItem;
import mrpheu.demo.server.interfaces.IMessageStrategy;
import mrpheu.demo.server.interfaces.IZoneClient;


public class MessageStrategyBroadcast implements IMessageStrategy {
    private MessageItem messageItem;
    private Map<Integer, IZoneClient> clientList;
    
    public MessageStrategyBroadcast(Map<Integer, IZoneClient> clientList, MessageItem messageItem) {
        this.clientList = clientList;
        this.messageItem = messageItem;
    }
    
    @Override
    public void process() {
        System.out.println("Broadcast active...");
        Set<Entry<Integer, IZoneClient>> entryList = this.clientList.entrySet();
        for(Entry<Integer, IZoneClient> entry : entryList) {
            //Integer key = keyList.nextElement();
            IZoneClient client = entry.getValue();
            client.update(messageItem);
        }
    }

}
